package com.fujitsu.cn.fnst.velocity.tool;

import java.util.List;

import org.apache.velocity.tools.config.DefaultKey;
import org.apache.velocity.tools.generic.SafeConfig;
import org.springframework.beans.factory.annotation.Configurable;
import org.springframework.context.annotation.DependsOn;
import org.springframework.context.annotation.Scope;

import com.fujitsu.cn.fnst.entiy.Meeting;
import com.fujitsu.cn.fnst.service.MeetingService;

@Configurable("meetingTool")
@DefaultKey("meetingTool")
@Scope
@DependsOn
public class MeetingTool extends SafeConfig {
    private MeetingService meetingService;

    public List<Meeting> getAllMeeting(int userRight) {
        return meetingService.findByWhereAndOrder(
                " meetingRight<=" + userRight,
                null);
    }

    public String getMeetingName(int id) {
        Meeting meeting = meetingService.find(id);
        if (meeting == null) {
            return "oops";
        } else {
            return meeting.getMeetingName();
        }
    }

    public Meeting getMeeting(int id) {
        return meetingService.find(id);
    }
    public MeetingService getMeetingService() {
        return meetingService;
    }

    public void setMeetingService(MeetingService meetingService) {
        this.meetingService = meetingService;
    }
}
